home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
FM Towns: Free Software Collection 6
/
FM Towns Free Software Collection 6.iso
/
t_os
/
et
/
src
/
mark.c
< prev
next >
Wrap
Text File
|
1993-07-08
|
15KB
|
506 lines
#include "et.h"
NAME *move_mouse(int *mos_b_p, int *key_b_p, NAME *name_b_p, int pq1_a[], int pq2_a[], int *start_p)/*et*/
{
int i, j, x, y, pq_a[4], name_a[4];
NAME *name_p;
if (!test_bit(G_f2, f2_MOUSE))
MOS_setpos(G_mn[mn_LL].p+8, G_mn[mn_LL].q+8);
while (1) {
MOS_rdpos(&i, &x, &y);
if (x < 8)
x = 8;
else if (x > 620)
x = 620;
else if (y < 1)
y = 1;
else if (y > 390)
y = 390;
else
break;
MOS_setpos(x, y);
}
name_p = find_pq(x, y);
if (!test_bit(G_f2, f2_MOUSE)) {
_copy_buf(pq2_a, name_p->pq, sizeof(int[4]));
pq2_a[2] += 8;
name_b_p = name_p;
}
if (!name_p) {
if (*mos_b_p) {
name_b_p = NULL;
if (!test_bit(G_f, f_PUSH) || find_pq(pq2_a[0]+1, pq2_a[1]+1)) {
copy_window(pq2_a, P_v[v_KEY_BUF], 0x14, POKE);
access_page();
copy_window(pq2_a, P_v[v_KEY_BUF], 0x14, POKE);
access_page();
}
_copy_buf(pq1_a, pq2_a, sizeof(int[4]));
copy_window(pq1_a, P_v[v_MOUSE_BUF], 0x14, PEEK);
}
if (x-24 < 8)
pq_a[0] = 8;
else
pq_a[0] = x-24;
if (y-23 < 8)
pq_a[1] = 8;
else
pq_a[1] = y-23;
if (x+48 > 639)
pq_a[2] = 639;
else
pq_a[2] = x+48;
if (y+32 > 399)
pq_a[3] = 399;
else
pq_a[3] = y+32;
if (!*start_p) {
copy_window(pq1_a, P_v[v_MOUSE_BUF], 0x14, POKE);
access_page();
copy_window(pq1_a, P_v[v_MOUSE_BUF], 0x14, POKE);
copy_window(pq_a, P_v[v_MOUSE_BUF], 0x14, PEEK);
access_page();
*start_p = 1;
}
copy_window(pq_a, P_v[v_MOUSE_BUF], 0x14, PEEK);
_copy_buf(pq1_a, pq_a, sizeof(int[4]));
copy_window(pq_a, P_v[v_KEY_TMP], 0x14, PEEK);
draw_mouse(pq_a);
copy_window(pq_a, P_v[v_MOUSE_TMP], 0x14, PEEK);
copy_window(pq_a, P_v[v_KEY_TMP], 0x14, POKE);
access_page();
copy_window(pq_a, P_v[v_MOUSE_TMP], 0x14, POKE);
access_page();
*mos_b_p = 0;
} else {
*mos_b_p = (name_p->key==_RET || name_p->key==S_RET) ? _RET : name_p->key;
if (!name_b_p) {
if (*mos_b_p == _RET)
_copy_buf(name_a, P_i[i_WIN_RET], sizeof(int[4]));
else
_copy_buf(name_a, name_p->pq, sizeof(int[4]));
name_a[2] += 8;
copy_window(pq1_a, P_v[v_MOUSE_BUF], 0x14, POKE);
copy_window(name_a, P_v[v_KEY_BUF], 0x14, PEEK);
if (*mos_b_p == _RET) {
paint_ret(0, L_WHT);
paint_ret(0, H_SYN);
} else {
if (name_p->key < ICN_I)
paint_window(name_p->pq, L_WHT, P_NEG);
paint_window(name_p->pq, H_SYN, P_NEG);
}
copy_window(name_a, P_v[v_KEY_TMP], 0x14, PEEK);
access_page();
copy_window(pq1_a, P_v[v_MOUSE_BUF], 0x14, POKE);
copy_window(name_a, P_v[v_KEY_TMP], 0x14, POKE);
access_page();
} else if (!test_bit(G_f2, f2_MOUSE) ||
(name_p != name_b_p && (*mos_b_p != _RET || *key_b_p != _RET))) {
if (!test_bit(G_f2, f2_MOUSE)) {
set_bit(G_f2, f2_MOUSE);
copy_window(pq2_a, P_v[v_KEY_BUF], 0x14, PEEK);
} else if (!test_bit(G_f, f_PUSH) || find_pq(pq2_a[0]+1, pq2_a[1]+1)) {
copy_window(pq2_a, P_v[v_KEY_BUF], 0x14, POKE);
access_page();
copy_window(pq2_a, P_v[v_KEY_BUF], 0x14, POKE);
access_page();
}
if (*mos_b_p == _RET)
_copy_buf(name_a, P_i[i_WIN_RET], sizeof(int[4]));
else
_copy_buf(name_a, name_p->pq, sizeof(int[4]));
name_a[2] += 8;
copy_window(name_a, P_v[v_MOUSE_TMP], 0x14, PEEK);
if (*mos_b_p == _RET) {
paint_ret(0, L_WHT);
paint_ret(0, H_SYN);
} else {
if (name_p->key < ICN_I)
paint_window(name_p->pq, L_WHT, P_NEG);
paint_window(name_p->pq, H_SYN, P_NEG);
}
copy_window(name_a, P_v[v_KEY_TMP], 0x14, PEEK);
access_page();
copy_window(name_a, P_v[v_KEY_TMP], 0x14, POKE);
if (!test_bit(G_f, f_PUSH) || find_pq(pq2_a[0]+1, pq2_a[1]+1)) {
copy_window(pq2_a, P_v[v_KEY_BUF], 0x14, POKE);
access_page();
copy_window(pq2_a, P_v[v_KEY_BUF], 0x14, POKE);
access_page();
}
copy_window(name_a, P_v[v_KEY_TMP], 0x14, POKE);
access_page();
copy_window(name_a, P_v[v_KEY_TMP], 0x14, POKE);
_copy_buf(P_v[v_KEY_BUF], P_v[v_MOUSE_TMP], BUF_SIZE * sizeof(unsigned));
*key_b_p = *mos_b_p;
}
if (*mos_b_p == _RET)
_copy_buf(pq2_a, P_i[i_WIN_RET], sizeof(int[4]));
else
_copy_buf(pq2_a, name_p->pq, sizeof(int[4]));
pq2_a[2] += 8;
name_b_p = name_p;
count(1);
}
res_bit(G_f, f_PUSH);
return(name_b_p);
}
void mark_icn(int file_i)/*et*/
{
int pq_a[4];
int i, j, k;
if (!file_i)
i = 1;
k = 0;
if (file_i) {
for (i = 1; i <= file_i; i++) {
read_icn(i);
if (test_bit(G_f, f_EE))
for (j = k = 0; !k && j <= G_nb.key; j++)
k = instring(i, G_id[j].csr, sizeof(char));
draw_icn(i, k);
set_icn_pq(pq_a, i, 0);
draw_frame4(pq_a, P_SET);
}
}
}
void copy_dot(DOT *Dst, DOT *Src)/*et*/
{
int i;
for (i = 0; i < N_LAST_DOT; i++) {
Dst->rnd[i] = Src->rnd[i];
Dst->rnd[i] = Src->rnd[i];
}
}
void draw_free(int mm)/*et*/
{
int i, key_n, free_n, free_i;
if (!mm)
draw_mode(1, mn_FREE_AREA, L_WHT);
key_n = nb_key(G_mv);
G_nb.dev_i = G_nb.mod_i = G_nb.dot_i = 0;
G_nb.dev = N_LAST_DOT * key_n / MAX_KEY;
clear_mark(P_dot[dot_FREE_AREA]);
G_nb.mod = 0;
mark_dot(P_dot[dot_FREE_AREA], MAX_KEY, 2, 1);
if (mm && !test_bit(G_f, f_DEMO) && G_nb.current != 16) {
G_nb.drive = *P_c[c_FILE_REPLAY];
free_n = _disk_free(0);
free_i = _disk_free(1);
G_nb.dev_i = G_nb.mod_i = G_nb.dot_i = 0;
G_nb.dev = N_LAST_DOT * (free_n - free_i) / free_n;
clear_mark(P_dot[dot_FREE_SAVE]);
G_nb.mod = 0;
mark_dot(P_dot[dot_FREE_SAVE], free_n, 2, 1);
G_nb.drive = *P_c[c_FILE_BAK];
free_n = _disk_free(0);
free_i = _disk_free(1);
G_nb.dev_i = G_nb.mod_i = G_nb.dot_i = 0;
G_nb.dev = N_LAST_DOT * (free_n - free_i) / free_n;
clear_mark(P_dot[dot_FREE_WORK]);
G_nb.mod = 0;
mark_dot(P_dot[dot_FREE_WORK], free_n, 2, 1);
}
}
void clear_mark(DOT *Dot)/*et*/
{
int i;
for (i = 0; i < N_LAST_DOT; i++) {
Dot->mpq[i].p = 0;
Dot->mpq[i].q = 0;
}
}
void shaff_dot(DOT *Dot)/*et*/
{
int i, j, k, *i_p;
char *s_p, *c_p;
if (test_bit(G_f, f_RND)) {
s_p = P_c[c_PATT_FONT];
for (j = N_LAST_DOT; j; j--)
*s_p++ = 0;
s_p = P_c[c_PATT_FONT];
j = k = 0;
while (j < N_LAST_DOT) {
i = rand()*N_LAST_DOT / RAND_MAX + 1;
if (!i || i > N_LAST_DOT)
continue;
c_p = s_p;
while (*c_p && *c_p != i)
c_p++;
if (*c_p)
continue;
*c_p = i;
Dot->rnd[j++] = i - 1;
}
} else
for (i = 0; i < N_LAST_DOT; i++)
Dot->rnd[i] = i;
}
void mark_dot(DOT *Dot, int key_n, int mm, int count)/*et*/
{
int i, j, k, draw_dots_m;
switch(mm) {
case 1:
G_nb.dev_i++;
if (G_nb.dev_i >= G_nb.dev) {
G_nb.dev_i -= G_nb.dev;
G_nb.mod_i += G_nb.mod;
if (G_nb.mod_i >= N_LAST_DOT) {
G_nb.mod_i -= N_LAST_DOT;
G_nb.dev_i--;
}
j = Dot->rnd[G_nb.dot_i];
if (Dot->mpq[j].p)
if (Dot->mpq[j].q)
draw_dots_m = 0;
else
draw_dots_m = 2;
else if (Dot->mpq[j].q)
draw_dots_m = 1;
else
draw_dots_m = 3;
draw_dots(Dot->pq[j].p, Dot->pq[j].q, draw_dots_m, count);
if (j % (N_LAST_DOT/4))
Dot->mpq[j-1].p = 1;
if (j >= N_LAST_DOT/4)
Dot->mpq[j-N_LAST_DOT/4].q = 1;
G_nb.dot_i++;
}
break;
case 2:
G_nb.mod_i += G_nb.mod;
if (G_nb.mod_i >= key_n) {
G_nb.mod_i -= key_n;
G_nb.dev_i = 1;
} else
G_nb.dev_i = 0;
for (k = G_nb.dot_i; G_nb.dot_i < k + G_nb.dev + G_nb.dev_i; G_nb.dot_i++) {
j = Dot->rnd[G_nb.dot_i];
if (Dot->mpq[j].p)
if (Dot->mpq[j].q)
draw_dots_m = 0;
else
draw_dots_m = 2;
else if (Dot->mpq[j].q)
draw_dots_m = 1;
else
draw_dots_m = 3;
draw_dots(Dot->pq[j].p, Dot->pq[j].q, draw_dots_m, count);
if (j % (N_LAST_DOT/4))
Dot->mpq[j-1].p = 1;
if (j >= (N_LAST_DOT/4))
Dot->mpq[j-N_LAST_DOT/4].q = 1;
}
break;
}
}
void draw_dots(int x, int y, int mm, int j)/*et*/
{
int i = j;
while (1) {
draw_line(x-1,y-1,x+4,y-1,L_WHT, P_SET);
draw_line(x-1,y-1,x-1,y+3,L_WHT, P_SET);
switch(mm) {
case 0:
break;
case 1:
draw_line(x+4,y+2,x+4,y-1,H_WHT, P_RES);
break;
case 2:
draw_line(x-1,y+3,x+4,y+3,H_WHT, P_RES);
break;
case 3:
draw_line(x-1,y+3,x+4,y+3,H_WHT, P_RES);
draw_line(x+4,y+2,x+4,y-1,H_WHT, P_RES);
break;
default:
break;
}
i--;
if (!i)
break;
access_page();
}
if (j == 2)
access_page();
}
void draw_mode(int mm, int menu_i, int col)/*et*/
{ /* SWITCH(mm) */
int i, len; /* CASE 0: pull_key() Draw_key() Draw_name() */
int key_len, name_len; /* CASE 1: push_key() Draw_name() */
FILE *File; /* CASE 2: pull_key() Draw_key() */
VRAM *vram_p, u; /* CASE 3: push_key() */
char *c_p; /* CASE 4: Draw_key() */
/* CASE 5: Draw_name() */
switch(mm) { /* CASE 6: pull_key() */
case 0: /* CASE 7: Draw_name() ... for draw_name() */
mark_key(mm, menu_i); /* CASE 8: Draw_name() ... for draw_name() */
c_p = G_mn[menu_i].font;/* CASE 9: push_key() Draw_key() */
len = strlen(G_mn[menu_i].s);
key_len = G_mn[menu_i].len;
name_len = len - key_len;
break;
case 1:
case 5:
case 7:
case 8:
c_p = G_mn[menu_i].font + G_mn[menu_i].len * 16;
len = strlen(G_mn[menu_i].s) - G_mn[menu_i].len;
key_len = 0;
name_len = len;
break;
case 9:
case 2:
mark_key((mm==2) ? mm : 1, menu_i);
case 4:
c_p = G_mn[menu_i].font;
len = G_mn[menu_i].len;
key_len = len;
name_len = 0;
break;
case 3:
case 6:
mark_key(mm, menu_i);
return;
break;
}
/* Draw_key() *//*et*/
for (i = 0; i < key_len; i++) {
vram_p = vram_addr(G_mn[menu_i].p + i * 8, G_mn[menu_i].q, !G_nb.page);
draw_name(&c_p, &vram_p, mm, col);
}
if (!mm)
mm = 5;
/* Draw_name() *//*et*/
for (i = 0; i < name_len; i++) {
vram_p = vram_addr(G_mn[menu_i].p + (i + G_mn[menu_i].len) * 8,
G_mn[menu_i].q, !G_nb.page);
draw_name(&c_p, &vram_p, mm, col);
}
if (mm == 1)
mark_key(mm, menu_i);
}
void mark_key(int mm, int menu_i)/*et*/
{
switch(menu_i) {
case mn_UP:
case mn_LT:
case mn_FR:
draw_key(G_mn[menu_i].p+5*8-1-1, G_mn[menu_i].q-1,
G_mn[menu_i].p+9*8+2+1-1, G_mn[menu_i].q+17, mm);
draw_key(G_mn[menu_i].p-1-1, G_mn[menu_i].q-1,
G_mn[menu_i].p+4*8+2+1-1, G_mn[menu_i].q+17, mm);
break;
case mn_S_UP:
case mn_S_LT:
case mn_S_FR:
draw_key(G_mn[menu_i].p+8*8-1-1+4, G_mn[menu_i].q-1,
G_mn[menu_i].p+11*8+2+1-1+4, G_mn[menu_i].q+17, mm);
draw_key(G_mn[menu_i].p+4*8-1-1+4, G_mn[menu_i].q-1,
G_mn[menu_i].p+7*8+2+1-1+4, G_mn[menu_i].q+17, mm);
draw_key(G_mn[menu_i].p-1-1+4, G_mn[menu_i].q-1,
G_mn[menu_i].p+3*8+2+1-1+4, G_mn[menu_i].q+17, 1);
break;
case mn_C_UP:
case mn_C_LT:
case mn_C_FR:
draw_key(G_mn[menu_i].p+7*8-1-1+4, G_mn[menu_i].q-1,
G_mn[menu_i].p+10*8+2+1-1+4, G_mn[menu_i].q+17, mm);
draw_key(G_mn[menu_i].p+3*8-1-1+4, G_mn[menu_i].q-1,
G_mn[menu_i].p+6*8+2+1-1+4, G_mn[menu_i].q+17, mm);
draw_key(G_mn[menu_i].p-1-1+4, G_mn[menu_i].q-1,
G_mn[menu_i].p+2*8+2+1-1+4, G_mn[menu_i].q+17, 1);
break;
case mn_C_DN:
case mn_C_RT:
case mn_C_BK:
case mn_S_DN:
case mn_S_RT:
case mn_S_BK:
draw_key(G_mn[menu_i].p-2+4, G_mn[menu_i].q-1,
G_mn[menu_i].p+G_mn[menu_i].len*8+2+4, G_mn[menu_i].q+17, mm);
break;
case mn_RET:
draw_ret(mm);
case mn_S_RET:
break;
case mn_LOGO:
draw_key(G_mn[menu_i].p-2,G_mn[menu_i].q-1-5,
G_mn[menu_i].p+G_mn[menu_i].len*8+2, G_mn[menu_i].q+24-5, mm);
break;
case mn_ERR:
case mn_ERR_1:
case mn_ERR_2:
case mn_ERR_3:
case mn_ERR_4:
draw_key(G_mn[menu_i].p-2,G_mn[menu_i].q-3,
G_mn[menu_i].p+G_mn[menu_i].len*8+2, G_mn[menu_i].q+18, mm);
break;
case mn_FF:
draw_key(G_mn[menu_i].p-2,G_mn[menu_i].q-1,
G_mn[menu_i].p+G_mn[menu_i].len*8, G_mn[menu_i].q+17, mm);
break;
case mn_RND:
case mn_POS:
draw_key(G_mn[menu_i].p-2,G_mn[menu_i].q-1,
G_mn[menu_i].p+G_mn[menu_i].len*8-1, G_mn[menu_i].q+17, mm);
break;
default:
draw_key(G_mn[menu_i].p-2, G_mn[menu_i].q-1,
G_mn[menu_i].p+G_mn[menu_i].len*8+2, G_mn[menu_i].q+17, mm);
break;
}
}
void set_trace_mode(int mm)/*et*/
{
int pq_a[4];
set_name_pq(mn_TAB, pq_a);
paint_window(pq_a, H_WHT, P_RES);
switch(mm) {
case f_AA:
draw_mode(5, mn_TAB, H_WHT);
break;
case f_NN:
draw_mode(5, mn_TAB, H_YEL);
break;
default:
draw_mode(5, mn_TAB, H_GRN);
break;
}
}
void mark_tab()/*et*/
{
int pq_a[4];
if (!test_bit(G_f, f_BAR))
if (!test_bit(G_f, f_TROFF))
set_trace_mode(test_bit(G_f, f_AA|f_NN));
else {
set_name_pq(mn_TAB, pq_a);
paint_window(pq_a, H_WHT, P_RES);
draw_mode(5, mn_TAB, L_WHT);
}
}
void mark_rev()/*et*/
{
int pq_a[4];
if (!test_bit(G_f, f_BAR)) {
set_name_pq(mn_INS, pq_a);
paint_window(pq_a, H_WHT, P_RES);
if (!test_bit(G_f, f_REV))
draw_mode(5, mn_INS, H_RED);
else
draw_mode(5, mn_INS, L_WHT);
}
}